home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
clang
/
gnumake.zip
/
PATCHES.OS2
< prev
next >
Wrap
Text File
|
1994-06-07
|
30KB
|
1,129 lines
Only in new: README.OS2
Only in new: patches.os2
Only in new: Makefile.os2
Only in new/glob: Makefile.os2
Only in new: make.def
Only in new: config.h
diff -cbr orig/function.c new/function.c
*** orig/function.c Fri Mar 04 07:36:26 1994
--- new/function.c Tue Jun 07 17:39:16 1994
***************
*** 377,388 ****
--- 377,394 ----
break;
}
+ #ifndef __EMX__
pid = vfork ();
if (pid < 0)
perror_with_name (error_prefix, "fork");
else if (pid == 0)
child_execute_job (0, pipedes[1], argv, envp);
else
+ #else
+ if((pid = child_execute_job(0,pipedes[1], argv, environ)) < 0) {
+ perror_with_name (error_prefix, "spawn");
+ }
+ #endif
{
/* We are the parent. */
diff -cbr orig/job.c new/job.c
*** orig/job.c Tue May 10 22:00:40 1994
--- new/job.c Tue Jun 07 18:40:28 1994
***************
*** 21,32 ****
#include "job.h"
#include "file.h"
#include "variable.h"
/* Default path to search for executables. */
static char default_path[] = ":/bin:/usr/bin";
-
/* Default shell to use. */
char default_shell[] = "/bin/sh";
/* If NGROUPS_MAX == 0 then try other methods for finding a real value. */
#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
--- 21,43 ----
#include "job.h"
#include "file.h"
#include "variable.h"
+ #ifdef __EMX__
+ #include <process.h>
+ #endif
+ #ifdef HAVE_FCNTL_H
+ #include <fcntl.h>
+ #endif
+ #ifndef __EMX__
/* Default path to search for executables. */
static char default_path[] = ":/bin:/usr/bin";
/* Default shell to use. */
char default_shell[] = "/bin/sh";
+ #else
+ /* I don't know what would pass for reasonable under OS/2 */
+ static char default_path[] = "\\os2;\\bin;\\usr\\bin";
+ char default_shell[] = "\\os2\\cmd.exe";
+ #endif
/* If NGROUPS_MAX == 0 then try other methods for finding a real value. */
#if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
***************
*** 650,655 ****
--- 661,667 ----
#endif
child->remote = 0;
+ #ifndef __EMX__
child->pid = vfork ();
if (child->pid == 0)
{
***************
*** 665,670 ****
--- 677,696 ----
perror_with_name ("vfork", "");
goto error;
}
+ #else
+ child->pid = child_execute_job(child->good_stdin ? 0 : bad_stdin, 1,
+ argv, child->environment);
+ /* if we've opened a pipe for the stdin of this command,
+ * close it after the spawn, since we don't exec and let
+ * the child handles croak of their own free will.
+ */
+ if(!child->good_stdin)
+ close(bad_stdin);
+ if(child->pid < 0) {
+ unblock_sigs();
+ goto error;
+ }
+ #endif
}
/* We are the parent side. Set the state to
***************
*** 979,994 ****
--- 1005,1030 ----
STDIN_FD and STDOUT_FD are used as the process's stdin and stdout; ENVP is
the environment of the new program. This function does not return. */
+ #ifndef __EMX__
void
+ #else
+ int
+ #endif
child_execute_job (stdin_fd, stdout_fd, argv, envp)
int stdin_fd, stdout_fd;
char **argv, **envp;
{
+ #ifdef __EMX__
+ int oldstdin = dup(0), oldstdout = dup(1), rval;
+ fcntl(oldstdin, F_SETFD, 1);
+ fcntl(oldstdout, F_SETFD, 1);
+ #endif
if (stdin_fd != 0)
(void) dup2 (stdin_fd, 0);
if (stdout_fd != 1)
(void) dup2 (stdout_fd, 1);
+ #ifndef __EMX__
/* Free up file descriptors. */
{
register int d;
***************
*** 996,1006 ****
for (d = 3; d < max; ++d)
(void) close (d);
}
-
/* Run the command. */
exec_command (argv, envp);
}
/* Search PATH for FILE.
If successful, store the full pathname in PROGRAM and return 1.
If not sucessful, return zero. */
--- 1032,1081 ----
for (d = 3; d < max; ++d)
(void) close (d);
}
/* Run the command. */
exec_command (argv, envp);
+ #else
+ rval = exec_command (argv, envp);
+ dup2(oldstdin,0); dup2(oldstdout,1);
+ close(oldstdin); close(oldstdout);
+ return rval;
+ #endif
}
+ /* Return one if the file is an internal SHELL command
+ Return zero otherwise
+ */
+ static int
+ is_shell_command(str)
+ char *str;
+ {
+ register int j;
+ #ifndef __EMX__
+ static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login",
+ "logout", "set", "umask", "wait", "while", "for",
+ "case", "if", ":", ".", "break", "continue",
+ "export", "read", "readonly", "shift", "times",
+ "trap", "switch", 0 };
+ for (j = 0; sh_cmds[j] != 0; ++j)
+ if (streq (sh_cmds[j], str))
+ return 1;
+ #else
+ static char *sh_cmds[] = {
+ "call","cd","chcp","chdir","cls","copy","date","del","detach",
+ "dir","do","echo","else","endlocal","erase","errorlevel","exist",
+ "exit","extproc","for","goto","if","in","keys","md","mkdir","move",
+ "not","path","pause","prompt","rd","rem","ren","rename","rmdir",
+ "set","setlocal","shift","start","time","type","ver","verify","vol",0
+ };
+ /* Shell command can be either upper or lower case */
+ for (j = 0; sh_cmds[j] != 0; ++j)
+ if(stricmp(sh_cmds[j], str) == 0)
+ return 1;
+ #endif
+ return 0;
+ }
+
+
/* Search PATH for FILE.
If successful, store the full pathname in PROGRAM and return 1.
If not sucessful, return zero. */
***************
*** 1012,1018 ****
--- 1087,1097 ----
if (path == 0 || path[0] == '\0')
path = default_path;
+ #ifndef __EMX__
if (index (file, '/') != 0)
+ #else
+ if (index(file,'/') != 0 || index (file, '\\') != 0 || file[1] == ':')
+ #endif
{
strcpy (program, file);
return 1;
***************
*** 1043,1055 ****
--- 1122,1148 ----
#endif /* Have getgroups. */
len = strlen (file) + 1;
+ #ifdef __EMX__
+ /* the standard OS/2 behavior is to look in CWD */
+ {
+ struct stat st;
+ if(stat(file,&st) == 0) {
+ strcpy(program,file);
+ return 1;
+ }
+ }
+ #endif
do
{
struct stat st;
int perm;
char *p;
+ #ifndef __EMX__
p = index (path, ':');
+ #else
+ p = index (path, ';');
+ #endif
if (p == 0)
p = path + strlen (path);
***************
*** 1094,1110 ****
return 0;
}
/* Replace the current process with one running the command in ARGV,
with environment ENVP. This function does not return. */
void
exec_command (argv, envp)
char **argv, **envp;
{
char *shell, *path;
PATH_VAR (program);
register char **ep;
!
shell = path = 0;
for (ep = envp; *ep != 0; ++ep)
{
--- 1187,1323 ----
return 0;
}
+ #ifdef __EMX__
+
+ /* Using something DOSISH all executables have extentions
+ /* So append these and then search for them in the path.
+ */
+ static int
+ emx_search_path (file, path, program)
+ char *file, *path, *program;
+ {
+ static char *suffixes[] = { ".exe", ".com", ".cmd", ".bat", NULL };
+ char *dot, tmp[PATH_MAX];
+ int i,namelen;
+
+ if (search_path(file,path,program)==1)
+ return 1;
+
+ if ((namelen = strlen(file)) < 4 || file[namelen-4] != '.') {
+ for (i = 0; suffixes[i]; i++) {
+ strcpy(tmp,file);
+ strcat(tmp,suffixes[i]);
+ if (search_path(tmp,path,program) == 1) {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ /* Have people call emx_search_path in the remainder of the program.
+ /* This will mimic regular behaviour.
+ */
+ #define search_path emx_search_path
+
+ /* Return zero if the file is not a script.
+ Return one if it is a script.
+ */
+ static int
+ is_script(file)
+ char *file;
+ {
+ static char *script_suffixes[] = { ".cmd", ".bat", NULL };
+ int i, namelen;
+ char *tmp;
+ struct stat st;
+ PATH_VAR(prog);
+
+ /* setup a temporary file name, which is lower case. */
+ namelen = strlen(file);
+ tmp = malloc(namelen+5);
+ strcpy(tmp,file);
+ strlwr(tmp);
+ for (i=0; script_suffixes[i]; i++) {
+ /* does it contain the extension */
+ if (strstr(file,script_suffixes[i])!=NULL) {
+ /* the user thinks it should be a script */
+ return 1;
+ } else {
+ if (file[namelen-4] == '.') {
+ /* it did have an extension so it can't be a script */
+ return 0;
+ } else {
+ /* append the extension and see if the file exists. */
+ tmp[namelen] = '\0';
+ strcat(tmp,script_suffixes[i]);
+ if(search_path (tmp, getenv("PATH"), prog)==1)
+ return 1;
+ }
+ }
+ }
+ /* should not be a script here */
+ return 0;
+ }
+
+ char *
+ os2_shell(for_cmd)
+ int for_cmd;
+ {
+ char *make_shell,*comspec,*os2_shell;
+
+ make_shell = getenv("MAKE_SHELL");
+ comspec = getenv("COMSPEC");
+ os2_shell = getenv("OS2_SHELL");
+
+ if(make_shell != NULL && !for_cmd)
+ return make_shell;
+ else if(comspec != NULL)
+ return comspec;
+ else if(os2_shell != NULL)
+ return os2_shell;
+ else
+ return default_shell;
+ }
+
+ int
+ is_cmd_exe(shell)
+ char *shell;
+ {
+ char basename[64];
+ _splitpath(shell, NULL, NULL, basename, NULL);
+ return (stricmp(basename,"4os2") == 0 || stricmp(basename,"cmd") == 0) ||
+ (stricmp(basename,"4dos") == 0 || stricmp(basename,"command") == 0);
+ }
+
+ #else
+
+ static int
+ is_script(file)
+ char *file;
+ { return 0;
+ }
+
+ #endif
+
/* Replace the current process with one running the command in ARGV,
with environment ENVP. This function does not return. */
+ #ifndef __EMX__
void
+ #else
+ int
+ #endif
exec_command (argv, envp)
char **argv, **envp;
{
char *shell, *path;
PATH_VAR (program);
register char **ep;
! #ifdef __EMX__
! int pid = -1;
! #endif
shell = path = 0;
for (ep = envp; *ep != 0; ++ep)
{
***************
*** 1115,1120 ****
--- 1328,1337 ----
else if (path != 0 && shell != 0)
break;
}
+ #ifdef __EMX__
+ if (shell == 0)
+ shell = os2_shell(0);
+ #endif
/* Be the user, permanently. */
child_access ();
***************
*** 1123,1137 ****
error ("%s: Command not found", argv[0]);
else
{
/* Run the program. */
execve (program, argv, envp);
-
if (errno == ENOEXEC)
{
PATH_VAR (shell_program);
char *shell_path;
if (shell == 0)
shell_path = default_shell;
else
{
if (search_path (shell, path, shell_program))
--- 1340,1364 ----
error ("%s: Command not found", argv[0]);
else
{
+ #ifndef __EMX__
/* Run the program. */
execve (program, argv, envp);
if (errno == ENOEXEC)
+ #else
+ pid = spawnve(P_NOWAIT,program,
+ (const char * const *)argv,
+ (const char * const *)envp);
+ if(pid == -1)
+ #endif
{
PATH_VAR (shell_program);
char *shell_path;
if (shell == 0)
+ #ifdef __EMX__
shell_path = default_shell;
+ #else
+ shell_path = os2_shell(1);
+ #endif
else
{
if (search_path (shell, path, shell_program))
***************
*** 1146,1175 ****
if (shell_path != 0)
{
char **new_argv;
! int argc;
argc = 1;
while (argv[argc] != 0)
++argc;
new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
new_argv[0] = shell_path;
! new_argv[1] = program;
while (argc > 0)
{
! new_argv[1 + argc] = argv[argc];
--argc;
}
execve (shell_path, new_argv, envp);
perror_with_name ("execve: ", shell_path);
}
}
else
perror_with_name ("execve: ", program);
}
!
_exit (127);
}
/* Figure out the argument list necessary to run LINE as a command.
--- 1373,1423 ----
if (shell_path != 0)
{
char **new_argv;
! int argc, arg;
argc = 1;
while (argv[argc] != 0)
++argc;
+ arg = 0;
+ #ifdef __EMX__
+ new_argv = (char **) alloca ((1 + argc + 2) * sizeof (char *));
+ new_argv[0] = shell_path;
+ new_argv[++arg] = "/c";
+ #else
new_argv = (char **) alloca ((1 + argc + 1) * sizeof (char *));
new_argv[0] = shell_path;
! #endif
! new_argv[++arg] = program;
while (argc > 0)
{
! new_argv[arg + argc] = argv[argc];
--argc;
}
+ /* Run the program. */
+ #ifndef __EMX__
execve (shell_path, new_argv, envp);
perror_with_name ("execve: ", shell_path);
+ #else
+ pid = spawnve(P_NOWAIT,shell_path,
+ (const char * const *)new_argv,
+ (const char * const *)envp);
+ if(pid == -1)
+ perror_with_name ("spawnve: ", shell_path);
+ #endif
}
}
+ #ifndef __EMX__
else
perror_with_name ("execve: ", program);
+ #endif
}
! #ifndef __EMX__
_exit (127);
+ #else
+ return pid;
+ #endif
}
/* Figure out the argument list necessary to run LINE as a command.
***************
*** 1189,1200 ****
char *line, **restp;
char *shell, *ifs;
{
static char sh_chars[] = "#;\"*?[]&|<>(){}$`^";
! static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login",
! "logout", "set", "umask", "wait", "while", "for",
! "case", "if", ":", ".", "break", "continue",
! "export", "read", "readonly", "shift", "times",
! "trap", "switch", 0 };
register int i;
register char *p;
register char *ap;
--- 1437,1448 ----
char *line, **restp;
char *shell, *ifs;
{
+ #ifndef __EMX__
static char sh_chars[] = "#;\"*?[]&|<>(){}$`^";
! #else
! static char sh_chars[] = "&|<>^()";
! int is_cmd = 1;
! #endif
register int i;
register char *p;
register char *ap;
***************
*** 1213,1221 ****
--- 1461,1476 ----
/* See if it is safe to parse commands internally. */
if (shell == 0)
+ #ifndef __EMX__
shell = default_shell;
else if (strcmp (shell, default_shell))
goto slow;
+ #else
+ shell = os2_shell(0);
+ else
+ if (!(is_cmd = is_cmd_exe(shell)))
+ goto slow;
+ #endif
if (ifs != 0)
for (ap = ifs; *ap != '\0'; ++ap)
***************
*** 1243,1252 ****
{
/* Inside a string, just copy any char except a closing quote
or a backslash-newline combination. */
! if (*p == '\'')
instring = 0;
else if (*p == '\\' && p[1] == '\n')
goto swallow_escaped_newline;
else if (*p == '\n' && restp != NULL)
{
/* End of the command line. */
--- 1498,1511 ----
{
/* Inside a string, just copy any char except a closing quote
or a backslash-newline combination. */
! if (*p == instring)
instring = 0;
else if (*p == '\\' && p[1] == '\n')
goto swallow_escaped_newline;
+ #ifdef __EMX__
+ else if (*p == '\\') /* except if guarded by \ */
+ *ap++ = *++p;
+ #endif
else if (*p == '\n' && restp != NULL)
{
/* End of the command line. */
***************
*** 1304,1316 ****
p = next_token (p) - 1;
}
}
! else if (p[1] != '\0')
/* Copy and skip the following char. */
*ap++ = *++p;
break;
case '\'':
! instring = 1;
break;
case '\n':
--- 1563,1585 ----
p = next_token (p) - 1;
}
}
! else if (p[1] != '\0') {
! #ifdef __EMX__
! /* for OS/2, let's keep single \ before characters and numbers
! because \ is commonly used as path name separator */
! if (isalnum(p[1]))
! *ap++ = *p;
! #endif
/* Copy and skip the following char. */
*ap++ = *++p;
+ }
break;
+ #ifdef __EMX__
+ case '"':
+ #endif
case '\'':
! instring = *p;
break;
case '\n':
***************
*** 1345,1358 ****
/* If this argument is the command name,
see if it is a built-in shell command.
If so, have the shell handle it. */
! if (i == 1)
! {
! register int j;
! for (j = 0; sh_cmds[j] != 0; ++j)
! if (streq (sh_cmds[j], new_argv[0]))
goto slow;
}
-
/* Ignore multiple whitespace chars. */
p = next_token (p);
/* Next iteration should examine the first nonwhite char. */
--- 1614,1627 ----
/* If this argument is the command name,
see if it is a built-in shell command.
If so, have the shell handle it. */
! if (i == 1) {
! if(is_shell_command(new_argv[0]))
! goto slow;
! #ifdef __EMX__
! if (is_script(new_argv[0]))
goto slow;
+ #endif
}
/* Ignore multiple whitespace chars. */
p = next_token (p);
/* Next iteration should examine the first nonwhite char. */
***************
*** 1379,1388 ****
if (i == 1)
{
! register int j;
! for (j = 0; sh_cmds[j] != 0; ++j)
! if (streq (sh_cmds[j], new_argv[0]))
goto slow;
}
if (new_argv[0] == 0)
--- 1648,1659 ----
if (i == 1)
{
! if (is_shell_command(new_argv[0]))
! goto slow;
! #ifndef __EMX__
! if (is_script(new_argv[0]))
goto slow;
+ #endif
}
if (new_argv[0] == 0)
***************
*** 1408,1424 ****
argument list. */
unsigned int shell_len = strlen (shell);
static char minus_c[] = " -c ";
unsigned int line_len = strlen (line);
!
! char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
+ (line_len * 2) + 1);
-
ap = new_line;
bcopy (shell, ap, shell_len);
ap += shell_len;
! bcopy (minus_c, ap, sizeof (minus_c) - 1);
! ap += sizeof (minus_c) - 1;
for (p = line; *p != '\0'; ++p)
{
if (restp != NULL && *p == '\n')
--- 1679,1704 ----
argument list. */
unsigned int shell_len = strlen (shell);
+ #ifndef __EMX__
static char minus_c[] = " -c ";
+ #define MINUS_C_SIZE sizeof(minus_c)
+ #else
+ char *minus_c = " /c ";
+ #define MINUS_C_SIZE (strlen(minus_c)+1)
+ #endif
unsigned int line_len = strlen (line);
! char *new_line;
! #ifdef __EMX__
! if(!is_cmd)
! minus_c = " -c ";
! #endif
! new_line = (char *) alloca (shell_len + (MINUS_C_SIZE - 1)
+ (line_len * 2) + 1);
ap = new_line;
bcopy (shell, ap, shell_len);
ap += shell_len;
! bcopy (minus_c, ap, MINUS_C_SIZE - 1);
! ap += MINUS_C_SIZE - 1;
for (p = line; *p != '\0'; ++p)
{
if (restp != NULL && *p == '\n')
***************
*** 1429,1455 ****
else if (*p == '\\' && p[1] == '\n')
{
/* Eat the backslash, the newline, and following whitespace,
! replacing it all with a single space (which is escaped
! from the shell). */
p += 2;
! /* If there is a tab after a backslash-newline,
! remove it from the source line which will be echoed,
! since it was most likely used to line
up the continued line with the previous one. */
! if (*p == '\t')
strcpy (p, p + 1);
p = next_token (p);
--p;
*ap++ = '\\';
*ap++ = ' ';
continue;
}
! if (*p == '\\' || *p == '\''
! || isspace (*p)
! || index (sh_chars, *p) != 0)
*ap++ = '\\';
*ap++ = *p;
}
--- 1709,1744 ----
else if (*p == '\\' && p[1] == '\n')
{
/* Eat the backslash, the newline, and following whitespace,
! replacing it all with a single space. */
p += 2;
! /* If there are tabs after a backslash-newline,
! remove them from the source line which will be echoed,
! since they were most likely used to line
up the continued line with the previous one. */
! while (*p == '\t')
strcpy (p, p + 1);
p = next_token (p);
--p;
+ #ifdef __EMX__
+ if (!is_cmd)
+ #endif
*ap++ = '\\';
*ap++ = ' ';
continue;
}
! if (*p == '\\' ||
! *p == '\'' ||
! #ifdef __EMX__
! *p == '"' ||
! #endif
! isspace (*p) ||
! index (sh_chars, *p) != 0)
! #ifdef __EMX__
! if(!is_cmd || index(sh_chars,*p) != 0)
! #endif
*ap++ = '\\';
*ap++ = *p;
}
diff -cbr orig/job.h new/job.h
*** orig/job.h Wed Mar 23 16:13:32 1994
--- new/job.h Tue Jun 07 17:39:20 1994
***************
*** 46,54 ****
extern void start_waiting_jobs ();
extern char **construct_command_argv ();
extern void child_execute_job ();
extern void exec_command ();
!
extern unsigned int job_slots_used;
#ifdef POSIX
--- 46,58 ----
extern void start_waiting_jobs ();
extern char **construct_command_argv ();
+ #ifndef __EMX__
extern void child_execute_job ();
extern void exec_command ();
! #else
! extern int child_execute_job ();
! extern int exec_command ();
! #endif
extern unsigned int job_slots_used;
#ifdef POSIX
diff -cbr orig/main.c new/main.c
*** orig/main.c Thu Apr 21 04:08:24 1994
--- new/main.c Tue Jun 07 17:39:22 1994
***************
*** 396,401 ****
--- 396,406 ----
PATH_VAR (current_directory);
char *directory_before_chdir;
+ #ifdef __EMX__
+ _response(&argc,&argv);
+ _wildcard(&argc,&argv);
+ #endif
+
default_goal_file = 0;
reading_filename = 0;
reading_lineno_ptr = 0;
***************
*** 607,616 ****
If it is a name with no slash, we can only hope that PATH did not
find it in the current directory.) */
if (current_directory[0] != '\0'
&& argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
argv[0] = concat (current_directory, "/", argv[0]);
!
(void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
/* Append the command-line variable definitions gathered above
--- 612,636 ----
If it is a name with no slash, we can only hope that PATH did not
find it in the current directory.) */
+ #ifndef __EMX__
if (current_directory[0] != '\0'
&& argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
argv[0] = concat (current_directory, "/", argv[0]);
! #else
! if (current_directory[0] != '\0' && /* there is a cwd */
! argv[0] != 0 && /* there is an argv[0] */
! (argv[0][0] != '/' && /* and it doesn't begin with slash */
! argv[0][0] != '\\' && /* or a backslash */
! argv[0][1] != ':') && /* or start with a drive letter */
! (index (argv[0], '/') != 0 || /* it does contain a slash */
! index (argv[0], '\\') != 0)) /* or a backslash */
! argv[0] = concat (current_directory, "/", argv[0]);
! {
! char *cp;
! for(cp = argv[0]; *cp != '\0'; cp++)
! *cp = (*cp == '\\') ? '/' : *cp;
! }
! #endif
(void) define_variable ("MAKE_COMMAND", 12, argv[0], o_default, 0);
/* Append the command-line variable definitions gathered above
***************
*** 694,704 ****
/* This makefile is standard input. Since we may re-exec
and thus re-read the makefiles, we read standard input
into a temporary file and read from that. */
! static char name[] = "/tmp/GmXXXXXX";
FILE *outfile;
/* Make a unique filename. */
! (void) mktemp (name);
outfile = fopen (name, "w");
if (outfile == 0)
--- 714,724 ----
/* This makefile is standard input. Since we may re-exec
and thus re-read the makefiles, we read standard input
into a temporary file and read from that. */
! char name[PATH_MAX];
FILE *outfile;
/* Make a unique filename. */
! tmpnam (name);
outfile = fopen (name, "w");
if (outfile == 0)
***************
*** 1054,1060 ****
--- 1074,1084 ----
fflush (stdout);
fflush (stderr);
+ #ifndef __EMX__
exec_command (argv, environ);
+ #else
+ exit(exec_command (argv, environ));
+ #endif
/* NOTREACHED */
}
}
***************
*** 1337,1343 ****
{
/* Print a nice usage message. */
- if (print_version_flag)
print_version ();
fprintf (stderr, "Usage: %s [options] [target] ...\n", program);
--- 1361,1366 ----
***************
*** 1758,1769 ****
if (print_version_flag)
print_version ();
/* Wait for children to die. */
for (err = status != 0; job_slots_used > 0; err = 0)
reap_children (1, err);
-
- /* Remove the intermediate files. */
- remove_intermediates (0);
if (print_data_base_flag)
print_data_base ();
--- 1781,1792 ----
if (print_version_flag)
print_version ();
+ /* Remove the intermediate files. */
+ remove_intermediates (0);
+
/* Wait for children to die. */
for (err = status != 0; job_slots_used > 0; err = 0)
reap_children (1, err);
if (print_data_base_flag)
print_data_base ();
diff -cbr orig/make.h new/make.h
*** orig/make.h Sat May 21 22:23:48 1994
--- new/make.h Tue Jun 07 17:39:22 1994
***************
*** 321,327 ****
--- 321,335 ----
#define getcwd(buf, len) getwd (buf)
#endif
+ #if defined(sgi) || defined(__EMX__)
extern char **environ;
+ #else
+ #ifndef NSIG
+ #define NSIG 33
+ #endif
+ extern char **_environ;
+ #define environ _environ
+ #endif
extern char *reading_filename;
extern unsigned int *reading_lineno_ptr;
diff -cbr orig/read.c new/read.c
*** orig/read.c Tue May 03 00:35:24 1994
--- new/read.c Tue Jun 07 21:27:34 1994
***************
*** 699,704 ****
--- 699,709 ----
/* Is this a static pattern rule: `target: %targ: %dep; ...'? */
p = index (p2, ':');
+ #ifdef __EMX__
+ /* allow path names with drive specifications (x:) */
+ if (p != 0 && !isspace(p[1]))
+ p = 0;
+ #endif
while (p != 0 && p[-1] == '\\')
{
register char *q = &p[-1];
***************
*** 1228,1233 ****
--- 1233,1242 ----
pattern_percent, percent);
free (d->name);
d->name = savestring (buffer, o - buffer);
+ #ifdef __EMX__
+ if (d->name[0] != '.')
+ _fnlwr(d->name);
+ #endif
}
}
***************
*** 1431,1438 ****
--- 1440,1456 ----
{
if (blank)
{
+ #ifdef __EMX__
+ while (*p != '\0' && !isblank (*p))
+ if (*p == stopchar && (stopchar != ':' || isblank(p[1]) ||
+ p[1] == 0 || p[1] == ':' || p[1] == ';'))
+ break;
+ else
+ ++p;
+ #else
while (*p != '\0' && *p != stopchar && !isblank (*p))
++p;
+ #endif
if (*p == '\0')
break;
}
***************
*** 1734,1739 ****
--- 1752,1759 ----
if (!backslash)
{
p[-1] = '\0';
+ if (p - p2 > 2)
+ p[-2] = '\0'; /* kill one of multiple backslashes */
break;
}
***************
*** 1934,1939 ****
--- 1954,1963 ----
{
free (old->name);
old->name = newname;
+ #ifdef __EMX__
+ if (old->name[0] != '.')
+ _fnlwr(old->name);
+ #endif
}
}
***************
*** 2004,2009 ****
--- 2028,2037 ----
struct nameseq *elt = (struct nameseq *) xmalloc (size);
elt->name = savestring (gl.gl_pathv[i],
strlen (gl.gl_pathv[i]));
+ #ifdef __EMX__
+ if (old->name[0] != '.')
+ _fnlwr(elt->name);
+ #endif
elt->next = new;
new = elt;
}
diff -cbr orig/variable.c new/variable.c
*** orig/variable.c Tue Apr 05 12:09:14 1994
--- new/variable.c Tue Jun 07 17:39:24 1994
***************
*** 366,371 ****
--- 366,372 ----
v = define_variable ("SHELL", 5, default_shell, o_default, 0);
v->export = v_export; /* Always export SHELL. */
+ #ifndef __EMX__
/* Don't let SHELL come from the environment. */
if (*v->value == '\0' || v->origin == o_env || v->origin == o_env_override)
{
***************
*** 373,378 ****
--- 374,388 ----
v->origin = o_file;
v->value = savestring (default_shell, strlen (default_shell));
}
+ #else
+ {
+ extern char *os2_shell(int);
+ char *cp = os2_shell(0);
+ v->value = savestring (cp, strlen(cp));
+ for(cp = v->value; *cp != '\0'; cp++)
+ *cp = (*cp == '\\' ? '/' : *cp);
+ }
+ #endif
/* Make sure MAKEFILES gets exported if it is set. */
v = define_variable ("MAKEFILES", 9, "", o_default, 0);
***************
*** 610,615 ****
--- 620,628 ----
--end;
p = next_token (p);
+ /* don't try to do this for empty names */
+ if(end < beg)
+ return 0;
/* Expand the name, so "$(foo)bar = baz" works. */
name = (char *) alloca (end - beg + 1);
bcopy (beg, name, end - beg);